<htnl>
<head>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta name="format-detection" content="telephone=no" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>备忘录</title>
	<style type="text/css">
		body{
			margin: 0;
		}
		#remark{
			margin: 0;
			padding: 0;
			height: 100%;
		}
		h4{
			margin: 0;
			padding: 0;
			text-align: center;
			font-size: 16px;
			border-bottom: 1px solid #999;
			box-shadow: 2px 6px 5px #ccc;
			font-weight: 400;
		}
		.content{
			/*margin: 10px 0 0 0;*/
			padding: 0 10px;

		}
		.warm{
			margin: 0;
		}
		#btn{
			position: absolute;
			left: 35%;
			bottom: 20px;
			width: 100px;
			height: 30px;
			border: 1px solid #ccc;
			border-radius: 5px;
			background: none;
		}
		#popm{
			position: absolute;
			left: 50%;
			bottom: 50%;
			height: 210px;
			width: 200px;
			margin-left: -100px;
			margin-bottom: -105px;
			padding: 0 10px;
			border: 1px solid #ccc;
			background: #fff;
		}
		.title{
			margin: 0;
			padding: 0;
			font-size: 16px;
			text-align: center;
		}
		.Submit{
			border: 1px solid #22a3dc;
			border-radius: 5px;
			background: none;
			margin-left: 50px;
			outline: none;
			margin-top:5px;
		}
		.Submit1{
			border: 1px solid #22a3dc;
			border-radius: 5px;
			background: none;
			margin-left: 10px;
			outline: none;
			margin-top:5px;
		}
		.content ul{
			margin: 0;
			padding: 0;
			list-style: none;
			/*background-color:#CCC;*/
		}
		.content ul li{
			white-space:nowrap; 
			overflow:hidden;
			list-style: none;
		}
		.content ul li .time{

		}
	</style>
</head>
<body>
		<div id="remark">
			<!--<h4>备忘录</h4>-->
			<div class="content">
				<ul class="ul_content">
					<li class="warm">
						暂无备忘录！
					</li>
				</ul>
			</div>
			<button id="btn">新&nbsp;&nbsp;建</button>
		</div>
		<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/common/common.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
		 function getUrlParam(name) {
		            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
		            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
		            if (r != null) return unescape(r[2]); return null; //返回参数值
		        }
		 var number = localStorage.getItem('number');
			if(number=='' || number == undefined){
				var number1 = getUrlParam('number');	
				localStorage.setItem('number',number1);
				var number = localStorage.getItem('number');
			}
		function Http(){
				var url =  server_url + 'a/zhtj/memo/getmemo';
				$.ajax({
				type:"get",
				url:url,
				async:true,
				json:"callback",
				data:{
				     number:number
					},
				dataType:'json',
				success:function(res){
					console.log(res)
					if(res.status == 0){
						console.log(res.data)
						if(res.data == undefined){
							
						}else{
							$('.warm').hide();
							$('.ul_content li').remove();
							console.log(res.data.length)
							for (var i = 0;i < res.data.length;i++) {
								console.log(res.data.content)
								var content = res.data[i].content;
								var id = res.data[i].id;
								var time = res.data[i].createDate;
								//生成一个备忘
								var m = $('<li class="con_p" style="position: relative;list-style: none;margin: 5px 0;"><a style="text-decoration: none;color: #000000;" href="bw_content.html?Id='+ id +'"><p style="white-space:nowrap;overflow:hidden;background: #fff;width: 50%;margin: 0;padding: 0;">'+ (i+1) +' 、'+ content +'</p ><span class="time" style="position: absolute;bottom: 2px;right: 5px;color: #C9C9C9;font-size: 12px;">'+ time +'</span></a></li>');
								m.appendTo('.ul_content');
							}
						}
					}
				}
			});
			}
		 Http();
			$("#btn").click(function(){
				$(".warm").hide();
				//动态生成一个弹框
				var main = $('<div id="popm"><h5 class="title">我要备忘</h5><textarea style="margin-left:5px;" rows="10" cols="22" class="mtext"></textarea><button class="Submit">提交</button><button class="Submit1">取消</button></div>');
				main.appendTo('body')
				
				var time = setInterval(function(){
					var content = $('.mtext').val();
					if(content == ''){
						$('.Submit').attr('disabled','disabled');
					}else{
						$('.Submit').removeAttr('disabled');
					}
				},200)
				//新增备忘  请求接口
				$(".Submit").click(function(){
					clearInterval(time);
					var content = $('.mtext').val();
					var url = server_url + 'a/zhtj/memo/savememo';
					console.log(content);
					$.ajax({
					type:"get",
					url:url,
					async:true,
					data:{
						number:number,
						content:content
					},
					dataType:'json',
					success:function(res){
						if(res.status == 0){
							console.log(res);
							$('#popm').remove();
							Http();
							}
						}
					});
				});
				
				$('.Submit1').click(function(){
					$('#popm').remove();
				})
			})
	
		</script>
	</body>
</htnl>